#include "../SpringImplementations/SpringAIInterface.h"
#include "ExternalAI/aibase.h"

#include "TAI/TAI.h"
#include "BAI/BlankAI.h"

#include "../OOInterface/AIInterface.h"

#include "../OOInterface/Objects/Logger.h"


static int aiTotal = 0;


DLL_EXPORT int GetGlobalAiVersion()
{
	return GLOBAL_AI_INTERFACE_VERSION;
}

DLL_EXPORT void GetAiName(char* name)
{
	strcpy(name, "SpringAI");
}

DLL_EXPORT IGlobalAI* GetNewAI()
{
	++aiTotal;
	SpringAIInterface* si = new SpringAIInterface;
	OOInterface::AIInterface* i = new OOInterface::AIInterface( si );

	new TAI( i );

	return si;
}

DLL_EXPORT void ReleaseAI(IGlobalAI* i)
{
	--aiTotal;
	delete i;

	if(aiTotal == 0)
		OOInterface::Logger::closeAll();

}

